﻿Imports System.Data.OleDb
Public Class Details2
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub



    Protected Sub Butt1_Click(sender As Object, e As EventArgs) Handles Butt1.Click
        Dim userC As String
        userC = Page.User.Identity.Name
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("roboticsConnectionString").ConnectionString)
        Dim SqlString As String = "Insert into Comments(Author,Comment,Title,RobotFCKID) Values (@f1,@f2,@f3,@f4)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", userC)
        cmd.Parameters.AddWithValue("@f2", tb_Comment.Text)
        cmd.Parameters.AddWithValue("@f3", tb_Title.Text)
        cmd.Parameters.AddWithValue("@f4", Request.Params("ID"))
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        oleDbConn.Close()

    End Sub

    Protected Sub ImgButton1_click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgButton1.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("roboticsConnectionString").ConnectionString)
        Dim SqlString As String = ""
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = System.Data.CommandType.Text
        ' updating winners
        cmd.CommandText = "UPDATE mastTable1 SET Likes = Likes + 1 WHERE ID = @f1"
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        oleDbConn.Close()
        img_Thumb.ImageUrl = "Pictures/Thumbs.jpeg"
    End Sub
End Class